package com.vova.test.es.starter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;

@Slf4j
@SpringBootApplication
public class DemoEsStarterApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DemoEsStarterApplication.class, args);
        try {
            ElasticsearchRestTemplate elasticsearchRestTemplate = context.getBean(ElasticsearchRestTemplate.class);
//            ItemRepository itemRepository = context.getBean(ItemRepository.class);
//            log.info("加载 itemRepository，{}", itemRepository.index(new Item()));
//            itemRepository.save(new Item(233L, "好东西啊", 2, 5.0d));
//            log.info("查询 是否存在233={}", itemRepository.existsById(233L));
        } catch (Exception e) {
            log.error("没有找到Bean");
        }
    }

}
